package nl.windgazer.arachne.internal.transform;

import nl.windgazer.arachne.annotations.IncludeOpenGraphMetaInfo;
import nl.windgazer.arachne.services.ArachneRenderSupport;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.internal.services.ComponentResourcesOperation;
import org.apache.tapestry5.ioc.services.SymbolSource;
import org.apache.tapestry5.model.MutableComponentModel;
import org.apache.tapestry5.plastic.PlasticClass;
import org.apache.tapestry5.services.ClassTransformation;
import org.apache.tapestry5.services.transform.ComponentClassTransformWorker2;
import org.apache.tapestry5.services.transform.TransformationSupport;

public class IncludeOpenGraphMetaInfoWorker implements
		ComponentClassTransformWorker2 {
//
//	private ArachneRenderSupport aRenderSupport;
//
//	public IncludeOpenGraphMetaInfoWorker(ArachneRenderSupport aRenderSupport, SymbolSource symbolSource)
//    {
//        this.aRenderSupport = aRenderSupport;
//    }
//
//	public void transform(ClassTransformation transformation, MutableComponentModel model) {
//		final IncludeOpenGraphMetaInfo annotation = transformation.getAnnotation(IncludeOpenGraphMetaInfo.class);
//		if (annotation != null) {
//
//	        ComponentResourcesOperation op = new ComponentResourcesOperation()
//	        {
//	            // Remember that ONE instances of this op will be injected into EVERY instance
//	            // of the component ... that means that we can't do any aggresive caching
//	            // inside the operation (the operation must be threadsafe).
//
//	            public void perform(ComponentResources resources)
//	            {
//	            	addOpenGraphMetaInfo(annotation.value(), aRenderSupport, resources);
//	            }
//	        };
//	        
//	        TransformationWorkerHelper.transform(transformation, model, op);
//		}
//	}
//
//	public static void addOpenGraphMetaInfo(final String[] values, final ArachneRenderSupport aRenderSupport, final ComponentResources resources) {
//		for (final String pair: values) {
//			final int marker = pair.indexOf('=');
//			if (marker>0) {
//				final String key = pair.substring(0, marker);
//				final String value = pair.substring(marker + 1);
//				addOpenGraphMetaInfo(key, value, aRenderSupport, resources);
//			}
//		}
//	}
//
//	/**
//	 * Adds a meta-info tag to ArachneRenderSupport and returns the translated message if a message: prefix was detected.
//	 * For values that are certain not to need translation, set resources param to null.
//	 * 
//	 * @param aRenderSupport
//	 * @param key
//	 * @param value
//	 * @param resources
//	 * @return
//	 */
//	public static String addOpenGraphMetaInfo(final String key, final String value, final ArachneRenderSupport aRenderSupport, final ComponentResources resources) {
//		if (resources!=null && value.startsWith("message:")) {
//			final String msgValue = resources.getMessages().get(value.substring(8));
//			aRenderSupport.addMetaTag("og:" + key, msgValue, "property");
//			return msgValue;
//		} else {
//			aRenderSupport.addMetaTag("og:" + key, value, "property");
//			return value;
//		}
//	}

	public void transform(PlasticClass arg0, TransformationSupport arg1,
			MutableComponentModel arg2) {
		// TODO Auto-generated method stub
		
	}

}
